package main

import "fmt"

/*
  外观模式
  例子 饭馆管理
  厨房和客户之间只隔着一个菜单和服务员

*/

//厨房采购
const (
	Status_Buy = iota
	Status_Stor
	Status_Cut
	Status_Cook
	Status_Eat
)

//蔬菜
type Vegetable struct {
	name string
	status int
}

func Buy(name string) *Vegetable {
	return &Vegetable{name:name,status:Status_Buy}
}

//保存买的蔬菜
var storage = make([]*Vegetable,0)
//保存蔬菜
func Save(vs []*Vegetable) {
	for _,v := range vs{
		v.status =Status_Stor
	}

	storage = append(storage,vs...)
}
//取出最后一个蔬菜
func GetLast() *Vegetable{
	v := storage[len(storage)-1]
	storage = storage[:len(storage)-1]
	return v
}

//切菜
func Cut(vs []*Vegetable) []*Vegetable  {
	for _,v := range vs{
		v.status = Status_Cut
	}
	return vs
}

//炒菜
func Cook(vs []*Vegetable) []*Vegetable  {

	for _,v := range vs{
		v.status = Status_Cook
	}
	return vs
}


//下单
func Make(list []string) []*Vegetable {
	//买菜
	vs := make([]*Vegetable,0)
	for _,l := range list {
		vs = append(vs,Buy(l))
	}
    //保存
    Save(vs)
    //煮菜
    vs = Cook(Cut(vs))
    return vs
}


//客户吃菜
func Eat(vs []*Vegetable){
	for _,v := range vs {
		v.status = Status_Eat
		fmt.Println(v)
	}
}


func main() {
	//客户下单和吃
	Eat(Make([]string{"生菜","辣椒","白菜","菜心"}))
	
}
